package com.exigen.performance.test.webapp.dao;

import java.util.List;

import javax.persistence.Query;

import com.exigen.performance.test.webapp.domain.ScenarioTypeEntity;
import com.exigen.performance.test.webapp.domain.base.GenericJPADAO;

/**
 * Class that selects scenario type entities from database.
 * 
 * @author Maksim Savchuk
 * 
 */
public class ScenarioTypeJpaDao extends GenericJPADAO<ScenarioTypeEntity, Long>
		implements ScenarioTypeDao {

	private final String query1 = "select distinct s from TestSummaryEntity t, ScenarioTypeEntity s where t.projectId= :projectId and t.scenarioId = :scenarioId and t.scenarioTypeId = s.id";

	public ScenarioTypeJpaDao() {
		super(ScenarioTypeEntity.class);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.exigen.performance.test.webapp.dao.ScenarioTypeDao#getScenatioType
	 * (java.lang.Long, java.lang.Long)
	 */
	public List<ScenarioTypeEntity> getScenatioType(Long projectId,
			Long scenarioId) {
		Query query = getEntityManager().createQuery(query1);
		query.setParameter("projectId", projectId);
		query.setParameter("scenarioId", scenarioId);
		@SuppressWarnings("unchecked")
		List<ScenarioTypeEntity> result = query.getResultList();
		return result;

	}

}
